Component({
  lifetimes: {
    attached: function () {
      // 在组件实例进入页面节点树时执行
      console.log(this.properties.option[0])
      let init = this.properties.option[0].text
      this.setData({
        initValue: init
      })
    },
    detached: function () {
      // 在组件实例被从页面节点树移除时执行
    },
  },
  properties: {
    option: {
      type: Array,
      value: []
    },
    value:{
      type: String,
      value: ''
    }
  },
  data: {
    initValue: '',
    isDown: true
  },
  methods: {
    click: function (e) {
     
    },
    toggleMenu(){
      let { isDown} = this.data
      this.setData({
        isDown: !isDown
      })
    },
    selectHandle(e){
      let id = e.currentTarget.dataset.selectoption
      this.triggerEvent('myevent',id)
      this.properties.option.forEach(item => {
        if(item.value == id){
          this.setData({
            initValue: item.text,
            isDown: true
          })
        }
      })
    }
  }
})